package com.tuweiya.study.springmvc001.eventBus;

import com.tuweiya.study.springmvc001.eventBus.observer.DataObserver1;
import com.tuweiya.study.springmvc001.eventBus.observer.DataObserver2;
import com.tuweiya.study.springmvc001.eventBus.subscriber.EventBusCenter;

/**
 * @Author: Mr_tu
 * @Date: Create in 14:40 2018/6/7
 * @Description: Guava EventBus 的测试主方法
 */
public class EventBusMain {

    public static void main(String[] args) {
        // 初始观察者
        DataObserver1 dataObserver1 = new DataObserver1();
        DataObserver2 dataObserver2 = new DataObserver2();

        // 往EventBus中注册
        EventBusCenter.register(dataObserver1);
        EventBusCenter.register(dataObserver2);

        System.out.println("============   start  ====================");

        System.out.println("111111");

        // 只有注册的参数类型为String的方法会被调用
        EventBusCenter.post("post string method");
        EventBusCenter.post(123);

        System.out.println("22222");
        System.out.println("3333");
        System.out.println("4444");


/*        System.out.println("============ after unregister ============");
        // 注销observer2
        EventBusCenter.unRegister(dataObserver2);
        EventBusCenter.post("post string method");
        EventBusCenter.post(123);*/

        System.out.println("============    end           =============");

    }


}
